﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using VAdvantage.Controls;
using System.Data;
using System.Collections;

namespace VAdvantage.Common
{
    public class FillCombo
    {
        /// <summary>
        /// Fills the comobox with data
        /// </summary>
        /// <param name="cmb">Object(combobox) which is to be filled</param>
        /// <param name="display_member">Name of the column whose value is to be on Display</param>
        /// <param name="value_member">Name of the column whose value is to be on Value</param>
        /// <param name="ds">Dataset which contains the data</param>
        public static void Fill(VComboBox cmb, string display_member, string value_member, DataSet ds)
        {
            //check if the dataset has table in it or not
            if (ds.Tables.Count >= 0)
            {
                cmb.ItemsSource = ds.Tables[0].GetBindableData(new Connector());  //set the data source of the objet to ds
                cmb.DisplayMemberPath = ds.Tables[0].Columns[display_member].ColumnName;    //set the display memeber
                cmb.ValueMemberPath = ds.Tables[0].Columns[value_member].ColumnName;    //set the value member
            }
        }
    }
}
